package com.yunkont.pigcontrol.fragment;

import android.graphics.Color;
import android.graphics.PointF;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.idtk.smallchart.chart.BarChart;
import com.idtk.smallchart.data.BarData;
import com.idtk.smallchart.interfaces.iData.IBarData;
import com.yunkont.pigcontrol.R;

import java.util.ArrayList;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by ZJB on 2017/9/21.
 *
 * @ copyright: iwhere chengdu technology
 */

public class FourthFragment extends Fragment {

    @Bind(R.id.img)
    ImageView img;
    @Bind(R.id.tv_pigName)
    TextView tvPigName;
    @Bind(R.id.tv_chooseName)
    TextView tvChooseName;
    @Bind(R.id.tv_pigStaute)
    TextView tvPigStaute;
    @Bind(R.id.tv_net)
    TextView tvNet;
    @Bind(R.id.bc_barChart)
    BarChart bcBarChart;
    private ArrayList<IBarData> mDataList = new ArrayList<>();
    private BarData mBarData = new BarData();
    private ArrayList<PointF> mPointArrayList = new ArrayList<>();

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View inflate = inflater.inflate(R.layout.fragment_first, container, false);
        ButterKnife.bind(this, inflate);
        initView();
        return inflate;
    }

    private void initView() {
        initData();
        bcBarChart.setBarWidth(getResources().getDimension(R.dimen.activity_chart_bar_));
        bcBarChart.setDataList(mDataList);
        bcBarChart.setXAxisUnit("X单位");
        bcBarChart.setYAxisUnit("Y单位");
    }

    private void initData() {

        for (int i = 0; i < 8; i++) {
            mPointArrayList.add(new PointF(i, i));
        }
        mBarData.setValue(mPointArrayList);
        mBarData.setColor(Color.CYAN);
        mBarData.setPaintWidth(10);
        mBarData.setTextSize(20);

        mDataList.add(mBarData);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
}
